import { _decorator, CCInteger, CCString } from 'cc';
import { ISensor } from './ISensor';
import { SensorComponent } from './SensorComponent';
import { BufferSensor } from './BufferSensor';
const { ccclass, property, menu } = _decorator;


@ccclass('BufferSensorComponent')
@menu("ML Agents/Buffer Sensor")
export class BufferSensorComponent extends SensorComponent {

    @property(CCString)
    sensorName: string = 'BufferSensor';

    /**
     * @en
     *  This is how many floats each entities will be represented with. This number
     * is fixed and all entities must have the same representation.
     * 
     * @zh
     * 这是每个实体将用多少个浮点数表示。这个数字是固定的，所有实体必须具有相同的表示。
     */
    @property(CCInteger)
    observationSize: number = 1;

    @property(CCInteger)
    public _maxNumObservables: number = 1;

    private _sensor: BufferSensor = null!;


    createSensors(): ISensor[] {
        this._sensor = new BufferSensor(this._maxNumObservables, this.observationSize, this.sensorName);
        return [this._sensor];
    }

    getSensor(): ISensor {
        return this._sensor;
    }


    appendObservation(obs: number[]): void {
        this._sensor.appendObservation(obs);
    }
}